 function dwrite(d,name,w,active,justRows,    line,col,row,sep,old,active1) {
   old = by("@ind_num_asc")
   if (isarray(active))  { 
     if(! justRows)
       print hwrite(name,w)
     for(row in active)
       print rwrite(row,d,w)
   } else {
     keys(d,active1)
     dwrite(d,name,w,active1)
   }
   by(old)
 } 
 function hwrite(name,w,         line,sep,old,col) {
   old = by("@ind_num_asc")
   for(col in w) {
     line = line sep name[col]
     sep = ","
   }
   by(old)
   return line
 }
 function rwrite(row,d,w,    col, line,sep,old) {
   old=by("@ind_num_asc")
   for(col in w) {
     line = line sep d[row][col]
     sep = "," 
   }
   by(old)
   return line 
 }
